using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SkiaSharp;

namespace FlowChartV2.Libraries
{
    public class Hexagon : Figure
    {
        public Hexagon(Point start, string text) : base(FigureTypes.Hexagon, text)
        {
            tsize = (int)new SKPaint().MeasureText(text) + 1;
            this.size = new Size(hfont + 10, Convert.ToInt32(tsize + 10));
            int hhsize = size.h / 2, hwsize = size.w / 2;
            this.start = new Point(start.x - hwsize, start.y);
            this.left = new Point(this.start.x - size.h, this.start.y + hhsize);
            this.bottom = new Point(this.start.x + hwsize, this.start.y + size.h);
            this.right = new Point(this.start.x + size.w + this.size.h, start.y + hhsize);
            this.top = new Point(this.start.x + hwsize, this.start.y);
            this.center = new Point(this.start.x + hwsize, this.start.y + hhsize);
        }
        public override void Draw(ref SKCanvas canvas, SKPaint paint)
        {
            SKPoint[] points =
            {
                new SKPoint(left.x,left.y),
                new SKPoint(start.x,start.y),

                new SKPoint(start.x,start.y),
                new SKPoint(start.x + size.w,start.y),

                new SKPoint(start.x + size.w,start.y),
                new SKPoint(right.x,right.y),


                new SKPoint(right.x,right.y),
                new SKPoint(start.x + size.w,start.y + size.h),

                new SKPoint(start.x + size.w,start.y + size.h),
                new SKPoint(start.x,start.y + size.h),

                new SKPoint(start.x,start.y + size.h),
                new SKPoint(left.x,left.y),
            };
            canvas.DrawPoints(SKPointMode.Lines, points, paint);
        }
        public override void DrawText(ref SKCanvas canvas, SKPaint paint)
        {
            int x = start.x + (size.w - tsize) / 2, y = (size.h + start.y) - size.h / 2 + 4;
            canvas.DrawText(text, x, y, paint);
        }
    }
}